#ifndef QPC_H
#define QPC_H

#include <QMainWindow>
#include <QMessageBox>
#include <QDateTime>
#include <QTimer>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QTextStream>
#include <QDialog>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QGridLayout>
#include <QAbstractScrollArea>
#include <QScrollBar>
#include <QCloseEvent>
#include <QImage>
#include "myserialport.h"
#include "mymath.h"
#include "VisionThread.h"
#include "communicationprotocol.h"
#include <QCameraInfo>
namespace Ui {
class QPC;
}

class QPC : public QMainWindow
{
    Q_OBJECT

public slots:
    void ReveiveSerialPortData(QByteArray data);
    void  ReveiveVisionData(float dx, float dy, float angle);
public:
    explicit QPC(QWidget *parent = 0);
    ~QPC();
    void ShowWaringInformation(QString info);
    void RefreshTimerUpdate();
    void SendTimerUpdate();
    void StartVisionThread();
    void StopVisionThread();
    void SetSupperSendDialog();
    void Delay_ms(int msec);

    //发送各种数据
    void SendVisionData_dx(float data);
    void SendVisionData_dy(float data);
    void SendVisionData_angle(float data);

    void closeEvent(QCloseEvent *event);

    QImage Mat2QImage(Mat cvImg);
private slots:
    void on_SeekSerialPort_pushButton_clicked();

    void on_OpenSerialPort_pushButton_clicked();

    void on_SendOrder_pushButton_clicked();

    void on_IsHex_checkBox_clicked();

    void on_TimeLine_checkBox_clicked();

    void on_IsAutoNewLine_checkBox_clicked();

    void on_IsDelayedTx_checkBox_clicked();

    void on_SaveData_pushButton_clicked();

    void on_Clear_pushButton_clicked();

    void on_SupperCom_pushButton_clicked();

    void on_OpenCamera_pushButton_clicked();

//    void on_SD_Send_Button_clicked();

    void on_isSendHex_checkBox_clicked();

    void on_SearchCamera_pushButtonn_clicked();

    void on_VisionClear_pushButton_clicked();


    void on_VisionClearData_pushButton_clicked();

    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

signals:
    void CameraStatus(bool ,int _ChossesCamera);

private:
    Ui::QPC *ui;
    QTimer *RefreshTimer;//更新界面定时器
    QTimer *SendTimer;//发送指令定时器
    MySerialPort *myserial;
    MyMath mymath;
    VisionThread *visionthread;
    CommunicationProtocol ComPro;

    QDialog *SupperSendDialg;
    QComboBox *SD_R_ID_ComboBox;
    QComboBox *SD_D_ID_ComboBox;
    QLineEdit *SD_Data_LineEdit;
    QPushButton *SD_Send_Button;
    QGridLayout *SDLayout;

   int nLine;
   int LineNum;
   QString Line1Name,Line2Name,Line3Name,Line4Name,Line5Name;
   int Value_AxisX;

   QStringList SD_R_Items;
   QStringList SD_D1_Items;//底盘数据ID总
   QStringList SD_D2_Items;//电源管理ID总
   QStringList SD_D3_Items;//手柄ID总
   QStringList SD_D4_Items;//其它单片机ID总

   bool isOSC;
   bool isHex;
   bool isTimeLine;
   bool isAutoNewLine;
   bool isDelayedTx;
   bool isSupperCom;
   bool isOpenCamera;
   bool VisionThread_Flag;

   QStringList CameraNum;
   QStringList SerialNum;
   QStringList SerialPortNameNum;
   QStringList Vision_Line_CD;
   int ChooseCamera;
   QImage QlinV;
   QImage QLine_Bethreshold;
   QImage QLine_Line;
   QImage QLine_Src;

public:
   int i=0;//计数变量（通信协议测试专用）
   QByteArray CP_data;//（通信协议测试专用）
   int j=0;
}
;

#endif // QPC_H
